package cate.common.table.farm.dailyfb;

import cate.common.table.ESheet;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DailyFbCombatSheet extends ESheet<DailyFbCombatRow> {
    @Override
    public String getSheetName() {
        return "日常副本";
    }
    @Override
    protected DailyFbCombatRow buildRow() {
        return new DailyFbCombatRow();
    }

    @NoteField(value = "<类型,该类型下不同条件副本>")
    private Map<Integer, List<DailyFbCombatRow>> typeMap = new HashMap<>();

    @Override
    protected void onRowCreated(DailyFbCombatRow row) {
        List<DailyFbCombatRow> rows = typeMap.get(row.type);
        if (rows == null) {
            rows = new ArrayList<>();
            typeMap.put(row.type, rows);
        }
        rows.add(row);
    }

    /** 根据副本类型列出 */
    public List<DailyFbCombatRow> listByType(int type) {
        return typeMap.get(type);
    }

    /** 根据 类型 和 第几关 查找模板数据 */
    public DailyFbCombatRow find(int type, int combatNum) {
        for (DailyFbCombatRow row : list) {
            if (row.type == type && row.combatNum == combatNum) {
                return row;
            }
        }
        return null;
    }

}
